#!/usr/bin/python3

from pydantic import BaseModel
from typing import Union, List

BUY_ACTION = "BUY"
SELL_ACTION = "SELL"
NONE_ACTION = "NONE"


class Response(BaseModel):
    status: int = 200
    msg: str = "Ok"
    tid: str = ""
    symbol: str = "000032.SZ"


class CBResponse(BaseModel):
    status: int = 200
    msg: str = "Ok"
    tid: str = ""
    symbol: str = "000032.SZ"
    name: str = ""
    method: str = ""
    day: str = ""
    action: str = "BUY/SELL/NONE"


class SharesDto(BaseModel):
    date: Union[str, None] = None
    open: Union[float, None] = None
    close: Union[float, None] = None
    preClose: Union[float, None] = None
    high: Union[float, None] = None
    low: Union[float, None] = None
    volume: Union[float, None] = None
    amount: Union[float, None] = None
    pctChg: Union[float, None] = None
    change: Union[float, None] = None


class QuantifyRequest(BaseModel):
    symbol: str = "000032.SZ"
    name: str = ""
    tid: str = ""
    method: str = ""
    salt: str = ""
    cbUrl: str = ""
    noise: int = 10
    items: Union[List[SharesDto], None] = None


class CnSharesDaily(BaseModel):
    symbol: str = ""
    trade_date: str = ""
    open: Union[float, None] = None
    close: Union[float, None] = None
    pre_close: Union[float, None] = None
    high: Union[float, None] = None
    low: Union[float, None] = None
    vol: Union[float, None] = None
    amount: Union[float, None] = None
    pct_chg: Union[float, None] = None
    change: Union[float, None] = None


class TjHqDailyRsp(BaseModel):
    code: int = 200
    msg: str = "OK"
    data: Union[List[CnSharesDaily], None] = None
